<?php
/**
 * Created by PhpStorm.
 * User: yuyiwen
 * Date: 2018/10/23
 * Time: 下午3:25
 */

namespace app\index\controller;


use think\Controller;

class Test extends Controller
{
    public function index ()
    {
//        $insert_data = ['src'=> 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1540448335103&di=b57196f67aabf336236f0ce38152ac30&imgtype=0&src=http%3A%2F%2Fimg.zcool.cn%2Fcommunity%2F0125fd5770dfa50000018c1b486f15.jpg%401280w_1l_2o_100sh.jpg', 'ord'=>1 , 'url'=>'https://www.baidu.com'];
//        $res = db('yysh_ad')->insert( $insert_data );
//        $res = db('yysh_ad')->insertGetId( $insert_data );

//        dump($res);
//            $update_data = ['url' => 'http://www.sina.com.cn' , 'id'=>8];
//            db('yysh_ad')->where('id' , 11)->update($update_data);
//            $res = db('yysh_ad')->update($update_data);
//            dump($res);// 影响的行数

//        $res = db('yysh_ad')->delete(7);
//        dump($res);
//            db('ad')->delete(6);


//            $info = db('ad')->find(3);
//            dump($info); // 1维数组

//            $info =   db('ad')->select();
//            dump($info); // 2维数组

//        $info = db('ad')->where(['id' => ['egt' , 2]])->where(['id' => ['lt' , 7]])->whereLike('url' , '%baidu%')->select();
//        $info = db('ad')->where(['id' => ['egt' , 2]])->whereLike('url' , '%baidu%')->select();

//            $info = db('ad')->order(['id'=>'desc'])->order('url')->limit(0 , 10)->buildSql();
//            echo  $info;

        # 使用聚合函数
//        echo db('ad')->count();
//        echo db('ad')->sum('ord');
//        echo db('ad')->min('ord');
//        echo db('ad')->max('ord');
//        echo db('ad')->avg('ord');

    }
}